package com.zretc.kscxmz.services.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zretc.kscxmz.entity.*;
import com.zretc.kscxmz.entity.Process;
import com.zretc.kscxmz.mappers.*;
import com.zretc.kscxmz.services.ProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ProcessServiceImpl implements ProcessService {

    @Autowired
    private ProcessMapper processMapper;
    @Autowired
    private CostWayMapper costWayMapper;
    @Autowired
    private EvectionTypeMapper evectionTypeMapper;
    @Autowired
    private OvertimeTypeMapper overtimeTypeMapper;
    @Autowired
    private UrgencyMapper urgencyMapper;
    @Autowired
    private VacateTypeMapper vacateTypeMapper;

    @Override
    public PageInfo<Process> getProcessList(Integer proposerId,Integer pageNum,Integer pageSize) {
        /*开始分页*/
        PageHelper.startPage(pageNum, pageSize);

        List<Process> list = processMapper.findAllProcess(proposerId);
        /*将list包装到pageinfo对象中去*/
        PageInfo<Process> pageInfo = new PageInfo<>(list);

        return pageInfo;
    }

    @Override
    public List<CostWay> getCostWayList() {
        return costWayMapper.findAllWay();
    }

    @Override
    public List<EvectionType> getEvectionTypeList() {
        return evectionTypeMapper.findAllEvectionType();
    }

    @Override
    public List<OvertimeType> getOvertimeTypeList() {
        return overtimeTypeMapper.findAllOvertimeType();
    }

    @Override
    public List<Urgency> getUrgencyList() {
        return urgencyMapper.findAllUrgency();
    }

    @Override
    public List<VacateType> getVacateTypeList() {
        return vacateTypeMapper.findAllVacateType();
    }

    @Override
    public int submitProcess(Process process) {
        return processMapper.insertProcess(process);
    }

    @Override
    public int modifyStatusById(Integer processId, Integer processStatus) {
        return processMapper.updateStatusById(processId,processStatus);
    }

    @Override
    public int deleteProcessById(Integer processId) {
        return processMapper.deleteProcessById(processId);
    }

}
